<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="PragmaticScala">
<meta name="generator" content="Paradox, paradox-material-theme=0.5.1, mkdocs-material=3.0.3">

<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="">
<meta name="lang:search.pipeline.stopwords" content="true">
<meta name="lang:search.pipeline.trimmer" content="true">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">


<meta name="description" content="PragmaticScala">
<link rel="shortcut icon" href="../assets/images/favicon.png">
<title>第13章——使用Actor编程 · </title>
<link rel="stylesheet" href="../assets/stylesheets/application.451f80e5.css">
<link rel="stylesheet" href="../lib/material__tabs/dist/mdc.tabs.min.css">
<link rel="stylesheet" href="../lib/prettify/prettify.css">
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
<style>
body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}
code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}
</style>
<link rel="stylesheet" href="../assets/fonts/font-awesome.css">
<link rel="stylesheet" href="../assets/fonts/material-icons.css">
<link rel="stylesheet" href="../assets/stylesheets/paradox-material-theme.css">
</head>
<body
>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="../index.html" title="" class="md-header-nav__button md-logo">
<i class="md-icon">local_library</i>
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">
</span>
<span class="md-header-nav__topic">
第13章——使用Actor编程
</span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
<label class="md-icon md-search__icon" for="__search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">&#xE5CD;</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>

</div>
</div>
</nav>
</header>

<div class="md-container">
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0" style="visibility: hidden">
<label class="md-nav__title md-nav__title--site" for="drawer">
<a href="../index.html" title="" class="md-nav__button md-logo">
<span class="md-nav__button md-logo">
<i class="md-icon">local_library</i>
</a>
<a href="../index.html" title="">
</a>
</label>
<ul>
  <li><a href="../contents.html" class="page">目录</a>
  <ul>
    <li><a href="../abstract.html" class="page">内容提要</a></li>
    <li><a href="../part1.html" class="page">第一部分 小试牛刀</a></li>
    <li><a href="../part2.html" class="page">第二部分 深入 Scala</a></li>
    <li><a href="../part3.html" class="page">第三部分 Scala 中的并发编程</a></li>
    <li><a href="../part4.html" class="page">第四部分 Scala 实战</a></li>
    <li><a href="../refs/references.html" class="page">参考书目</a></li>
    <li><a href="../extras.html" class="page">额外指引</a></li>
    <li><a href="../errata.html" class="page">勘误</a></li>
  </ul></li>
</ul>
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">Table of contents</label>
<ul>
  <li><a href="../chapter-13/index.html#第13章-使用actor编程" class="header">第13章——使用Actor编程</a>
  <ul>
    <li><a href="../chapter-13/index.html#13-1-一个顺序耗时问题" class="header">13.1 一个顺序耗时问题</a></li>
    <li><a href="../chapter-13/index.html#13-3-创建-actor" class="header">13.3 创建 Actor</a></li>
    <li><a href="../chapter-13/index.html#13-4-actor-和线程" class="header">13.4 Actor 和线程</a></li>
    <li><a href="../chapter-13/index.html#13-5-隔离可变性" class="header">13.5 隔离可变性</a></li>
    <li><a href="../chapter-13/index.html#13-6-使用-actor-模型进行并发" class="header">13.6 使用 Actor 模型进行并发</a></li>
  </ul></li>
</ul>
</nav>

</nav>
<ul style="display: none">
<li class="md-nav__item md-version" id="project.version">
<label class="md-nav__link" for="__version">
<i class="md-icon" title="Version">label_outline</i> 1.0.0
</label>
</li>
</ul>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">Table of contents</label>
<ul>
  <li><a href="../chapter-13/index.html#第13章-使用actor编程" class="header">第13章——使用Actor编程</a>
  <ul>
    <li><a href="../chapter-13/index.html#13-1-一个顺序耗时问题" class="header">13.1 一个顺序耗时问题</a></li>
    <li><a href="../chapter-13/index.html#13-3-创建-actor" class="header">13.3 创建 Actor</a></li>
    <li><a href="../chapter-13/index.html#13-4-actor-和线程" class="header">13.4 Actor 和线程</a></li>
    <li><a href="../chapter-13/index.html#13-5-隔离可变性" class="header">13.5 隔离可变性</a></li>
    <li><a href="../chapter-13/index.html#13-6-使用-actor-模型进行并发" class="header">13.6 使用 Actor 模型进行并发</a></li>
  </ul></li>
</ul>
</nav>

</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset">
<div class="md-content__searchable">
<h1><a href="#第13章-使用actor编程" name="第13章-使用actor编程" class="anchor"><span class="anchor-link"></span></a>第13章——使用Actor编程</h1>
<p>在编写复杂、耗时的应用程序时，我们经常会使用多线程以及并发来降低响应时间或者 提高性能。可惜，传统的并发解决方案导致了一些问题，如线程安全、竞态条件、死锁、活 锁以及不容易理解的、容易出错的代码。共享的可变性是罪魁祸首。</p>
<h2><a href="#13-1-一个顺序耗时问题" name="13-1-一个顺序耗时问题" class="anchor"><span class="anchor-link"></span></a>13.1 一个顺序耗时问题</h2>
<blockquote>
  <p>ProgrammingActors/CountFilesSequential.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import java.io.File

def getChildren(file: File) = {
  val children = file.listFiles()
  if (children != null) children.toList else List()
}

val start = System.nanoTime
val exploreFrom = new File(args(0))

var count = 0L
var filesToVisit = List(exploreFrom)

while (filesToVisit.nonEmpty) {
  val head = filesToVisit.head
  filesToVisit = filesToVisit.tail

  val children = getChildren(head)
  count = count + children.count { !_.isDirectory }
  filesToVisit = filesToVisit ::: children.filter { _.isDirectory }
}

val end = System.nanoTime
println(s&quot;Number of files found: $count&quot;)
println(s&quot;Time taken: ${(end - start) / 1.0e9} seconds&quot;)</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/CountFilesSequential.scala#L21-L45">Full source at GitHub</a>
<p><em>执行命令</em></p>
<pre class="prettyprint"><code class="language-sh">scala countFilesSequential.scala /Users/venkats/agility</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/RunCountFilesSequential.sh#L4">Full source at GitHub</a>
<p><em>运行结果</em></p>
<pre class="prettyprint"><code class="language-output">Number of files found: 479758
Time taken: 66.524453436 seconds</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/shoutput/RunCountFilesSequential.output#L2-L3">Full source at GitHub</a>
<h2><a href="#13-3-创建-actor" name="13-3-创建-actor" class="anchor"><span class="anchor-link"></span></a>13.3 创建 Actor</h2>
<blockquote>
  <p>ProgrammingActors/HollywoodActor.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import akka.actor._

class HollywoodActor() extends Actor {
  def receive: Receive = {
    case message ⇒ println(s&quot;playing the role of $message&quot;)
  }
}</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/HollywoodActor.scala#L20-L26">Full source at GitHub</a>
<p><em>执行命令——编译</em></p>
<pre class="prettyprint"><code class="language-sh">scalac -d classes HollywoodActor.scala CreateActors.scala</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/RunCreateActors.sh#L5">Full source at GitHub</a>
<p><em>执行命令——执行</em></p>
<pre class="prettyprint"><code class="language-sh">scala -classpath classes CreateActors</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/RunCreateActors.sh#L9">Full source at GitHub</a>
<blockquote>
  <p>ProgrammingActors/CreateActors.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import akka.actor._

import scala.concurrent.Await
import scala.concurrent.duration.Duration

object CreateActors extends App {
  val system = ActorSystem(&quot;sample&quot;)

  val depp = system.actorOf(Props[HollywoodActor])

  depp ! &quot;Wonka&quot;

  val terminateFuture = system.terminate()
  Await.ready(terminateFuture, Duration.Inf)
}</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/CreateActors.scala#L20-L34">Full source at GitHub</a>
<p><em>运行结果</em></p>
<pre class="prettyprint"><code class="language-output">playing the role of Wonka</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/shoutput/RunCreateActors.output#L2">Full source at GitHub</a>
<blockquote>
  <p>ProgrammingActors/HollywoodActor2.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">case message ⇒ println(s&quot;$message - ${Thread.currentThread}&quot;)</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/HollywoodActor2.scala#L26">Full source at GitHub</a>
<blockquote>
  <p>ProgrammingActors/CreateActors2.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">val depp = system.actorOf(Props[HollywoodActor])
val hanks = system.actorOf(Props[HollywoodActor])

depp ! &quot;Wonka&quot;
hanks ! &quot;Gump&quot;

depp ! &quot;Sparrow&quot;
hanks ! &quot;Phillips&quot;
println(s&quot;Calling from ${Thread.currentThread}&quot;)</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/CreateActors2.scala#L28-L36">Full source at GitHub</a>
<p><em>运行结果</em></p>
<pre class="prettyprint"><code class="language-output">Wonka - Thread[sample-akka.actor.default-dispatcher-2,5,main]
Gump - Thread[sample-akka.actor.default-dispatcher-3,5,main]
Calling from Thread[main,5,main]
Phillips - Thread[sample-akka.actor.default-dispatcher-3,5,main]
Sparrow - Thread[sample-akka.actor.default-dispatcher-2,5,main]</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/shoutput/RunCreateActors2.output#L2-L6">Full source at GitHub</a>
<h2><a href="#13-4-actor-和线程" name="13-4-actor-和线程" class="anchor"><span class="anchor-link"></span></a>13.4 Actor 和线程</h2>
<blockquote>
  <p>ProgrammingActors/CreateActors3.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">depp ! &quot;Wonka&quot;
hanks ! &quot;Gump&quot;

Thread.sleep(100)

depp ! &quot;Sparrow&quot;
hanks ! &quot;Phillips&quot;</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/CreateActors3.scala#L31-L37">Full source at GitHub</a>
<p><em>运行结果</em></p>
<pre class="prettyprint"><code class="language-output">Wonka - Thread[sample-akka.actor.default-dispatcher-3,5,main]
Gump - Thread[sample-akka.actor.default-dispatcher-4,5,main]
Sparrow - Thread[sample-akka.actor.default-dispatcher-4,5,main]
Phillips - Thread[sample-akka.actor.default-dispatcher-3,5,main]
Calling from Thread[main,5,main]</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/shoutput/RunCreateActors3.output#L2-L6">Full source at GitHub</a>
<h2><a href="#13-5-隔离可变性" name="13-5-隔离可变性" class="anchor"><span class="anchor-link"></span></a>13.5 隔离可变性</h2>
<blockquote>
  <p>ProgrammingActors/HollywoodActor4.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import akka.actor._
import scala.collection._

case class Play(role: String)
case class ReportCount(role: String)

class HollywoodActor() extends Actor {
  val messagesCount: mutable.Map[String, Int] = mutable.Map()

  def receive: Receive = {
    case Play(role) ⇒
      val currentCount = messagesCount.getOrElse(role, 0)
      messagesCount.update(role, currentCount + 1)
      println(s&quot;Playing $role&quot;)

    case ReportCount(role) ⇒
      sender ! messagesCount.getOrElse(role, 0)
  }
}</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/HollywoodActor4.scala#L21-L39">Full source at GitHub</a>
<blockquote>
  <p>ProgrammingActors/UseActor.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import akka.actor._
import akka.pattern.ask
import akka.util.Timeout

import scala.concurrent.Await
import scala.concurrent.duration._

object UseActor extends App {

  case class Play(role: String)

  case class ReportCount(role: String)

  val system = ActorSystem(&quot;sample&quot;)

  val depp = system.actorOf(Props[HollywoodActor])
  val hanks = system.actorOf(Props[HollywoodActor])

  depp ! Play(&quot;Wonka&quot;)
  hanks ! Play(&quot;Gump&quot;)

  depp ! Play(&quot;Wonka&quot;)
  depp ! Play(&quot;Sparrow&quot;)

  println(&quot;Sent roles to play&quot;)

  implicit val timeout: Timeout = Timeout(2.seconds)
  val wonkaFuture = depp ? ReportCount(&quot;Wonka&quot;)
  val sparrowFuture = depp ? ReportCount(&quot;Sparrow&quot;)
  val gumpFuture = hanks ? ReportCount(&quot;Gump&quot;)

  val wonkaCount = Await.result(wonkaFuture, timeout.duration)
  val sparrowCount = Await.result(sparrowFuture, timeout.duration)
  val gumpCount = Await.result(gumpFuture, timeout.duration)

  println(s&quot;Depp played Wonka $wonkaCount time(s)&quot;)
  println(s&quot;Depp played Sparrow $sparrowCount time(s)&quot;)
  println(s&quot;Hanks played Gump $gumpCount time(s)&quot;)

  val terminateFuture = system.terminate()
  Await.ready(terminateFuture, Duration.Inf)
}

case class Play(role: String)

case class ReportCount(role: String)
</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/UseActor.scala#L20-L66">Full source at GitHub</a>
<p><em>运行结果</em></p>
<pre class="prettyprint"><code class="language-output">Sent roles to play
Playing Wonka
Playing Gump
Playing Wonka
Playing Sparrow
Depp played Wonka 2 time(s)
Depp played Sparrow 1 time(s)
Hanks played Gump 1 time(s)</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/shoutput/RunUseActor.output#L2-L9">Full source at GitHub</a>
<h2><a href="#13-6-使用-actor-模型进行并发" name="13-6-使用-actor-模型进行并发" class="anchor"><span class="anchor-link"></span></a>13.6 使用 Actor 模型进行并发</h2>
<blockquote>
  <p>ProgrammingActors/FileExplorer.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import akka.actor._
import java.io._

class FileExplorer extends Actor {
  def receive: Receive = {
    case dirName: String ⇒
      val file = new File(dirName)
      val children = file.listFiles()
      var filesCount = 0

      if (children != null) {
        children.filter { _.isDirectory }
          .foreach { sender ! _.getAbsolutePath }
        filesCount = children.count { !_.isDirectory }
      }

      sender ! filesCount
  }
}</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/FileExplorer.scala#L20-L38">Full source at GitHub</a>
<blockquote>
  <p>ProgrammingActors/FilesCounter.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import akka.actor._
import akka.routing._

class FilesCounter extends Actor {
  val start: Long = System.nanoTime
  var filesCount = 0L
  var pending = 0

  val fileExplorers: ActorRef =
    context.actorOf(RoundRobinPool(100).props(Props[FileExplorer]))

  def receive: Receive = {
    case dirName: String ⇒
      pending = pending + 1
      fileExplorers ! dirName

    case count: Int ⇒
      filesCount = filesCount + count
      pending = pending - 1

      if (pending == 0) {
        val end = System.nanoTime
        println(s&quot;Files count: $filesCount&quot;)
        println(s&quot;Time taken: ${(end - start) / 1.0e9} seconds&quot;)
        context.system.terminate()
      }
  }
}
</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/FilesCounter.scala#L20-L48">Full source at GitHub</a>
<blockquote>
  <p>ProgrammingActors/CountFiles.scala</p>
</blockquote>
<pre class="prettyprint"><code class="language-scala">import akka.actor._

object CountFiles extends App {
  val system = ActorSystem(&quot;sample&quot;)

  val filesCounter = system.actorOf(Props[FilesCounter])

  filesCounter ! args(0)
}</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/CountFiles.scala#L20-L28">Full source at GitHub</a>
<p><em>执行命令</em></p>
<pre class="prettyprint"><code class="language-sh">scalac -d classes FilesCounter.scala FileExplorer.scala CountFiles.scala
scala -classpath classes CountFiles /Users/venkats/agility</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/RunCountFiles.sh#L5-L6">Full source at GitHub</a>
<p><em>运行结果</em></p>
<pre class="prettyprint"><code class="language-output">Files count: 479758
Time taken: 5.609851764 seconds</code></pre><a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/v1.0.0/src/main/scala/chapter13/shoutput/RunCountFiles.output#L2-L3">Full source at GitHub</a>
</div>
<div>
<a href="https://github.com/ReactivePlatform/Pragmatic-Scala.git/tree/master/src/paradox/chapter-13/index.md" title="Edit this page" class="md-source-file md-edit">
Edit this page
</a>
</div>
<div class="print-only">
<span class="md-source-file md-version">
1.0.0
</span>
</div>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../chapter-12/index.html" title="第12章——惰性求值和并行集合" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Previous
</span>
第12章——惰性求值和并行集合
</span>
</div>
</a>
<a href="../part4.html" title="第四部分 Scala 实战" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Next
</span>
第四部分 Scala 实战
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
Powered by
<a href="https://github.com/lightbend/paradox">Paradox</a>
and
<a href="https://jonas.github.io/paradox-material-theme/">Paradox Material Theme</a>

</div>
</div>
</div>
</footer>

</div>
<script src="../assets/javascripts/application.583bbe55.js"></script>
<script src="../assets/javascripts/paradox-material-theme.js"></script>
<script>app.initialize({version:"0.17",url:{base:"../."}})</script>
<script type="text/javascript" src="../lib/prettify/prettify.js"></script>
<script type="text/javascript" src="../lib/prettify/lang-scala.js"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
window.prettyPrint && prettyPrint();
});
</script>
</body>
</html>
